m = {}

def findkey(s):
    for k, v in m.iteritems():
        if v == s:
            return k
    return False
def add(k, v):
    m[k] = v
add("object", "animal")
add("animal", "feline")
add("feline", "cat")
add("cat", "dan")
print m

def ev(s):
    if s.find("=") == -1:
        if '*' in s:
            s = s.replace('*','')
            s = s.replace(' ','')
            if not s.isalpha(): print "only letters"; return None
            if m[s] not in m: print "no data at:", m[s]; return None
            return print m[m[s]]

        if '&' in s:
            s = s.replace('&','')
            s = s.replace(' ','')
            if not s.isalpha(): print "only letters"; return None
            if s not in m.values(): print "value not found: value", s; return None
            k = findkey(s)
            if k == False: print "impossible. please contact us."; return None
            return k
    if s.find("=") == -1:

        if not s.isalpha(): print "only letters"; return
        if s not in m: print "not found:", s; return
        return m[s]
    else:
        s = s.replace(' ','')
        sym = s.split("=")
        if len(sym) < 2: print "syntax error, can't find '=' symbol"; return
        m[sym[0]] = sym[1] # oh yeah


while True:
    print ">",
    s = raw_input()
    if s == '0': print "exiting"; break
    ev(s)


